<template>
  <div class="address_wrap">
    <navtop title="地址管理" path="/order"></navtop>
    <div class="vanlist">
      <van-address-list
        class="address"
        
        :list="addressdata.addresslist"
        default-tag-text="默认"
        @add="onAdd"
        @edit="onEdit"
        @select="checked"
      />
    </div>
  </div>
</template>

<script>
import { Toast } from "vant";
import navtop from "./navtop";
import { mapState, mapGetters, mapMutations } from "vuex";

export default {
  components: {
    navtop,
  },

  computed: {
    // ...mapState(["addressdata", "addressList"]),
  },
  data() {
    return {
      choose: [],
      addressdata: {
        addresslist: [],
      },
    };
  },
  mounted() {
   
    this.addressdata.addresslist = JSON.parse(
      localStorage.getItem("addressdata")
    );
   
  },
  methods: {
    onAdd() {
      Toast("新增地址");
      this.$router.push("editaddress");
    },
    onEdit(item, index) {
      Toast("编辑地址:" + index);
      this.$router.push({path:"/bianjiaddress",query:{index}});
      // console.log(item);
      // this.$store.commit('editdata', item);
    },
    checked(item, index) {
      // console.log(item, IDBIndex);
      let item1=JSON.stringify(item);
      
      localStorage.setItem("shouhuoaddress",item1)
      this.$router.push("/order");
    },
  },
};
</script>

<style lang="less" scoped>
.vanlist {
  /deep/.van-radio__icon {
    display: none;
  }
}
</style>